import request from '@/utils/request'
// import store from '@/store'

/**
 * 登录接口
 * @param {string} mobile 手机号
 * @param {string} code 验证码
 * @returns
 */
export function login (mobile, code) {
  return request({
    method: 'post',
    url: '/v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })
}

/**
 * 获取用户接口
 * @returns promise对象
 */
export function getUserInfo () {
  return request({
    method: 'get',
    url: '/v1_0/user/profile'
    // headers: {
    //   Authorization: 'Bearer ' + store.state.user.token.token
    // }
  })
}

/**
 * 修改用户资料
 * @param {object} data 用户个人信息
 * @returns
 */
export function updateUserInfo(data) {
  console.log(data, 2222)
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data: data
  })
}

/**
 *  修改用户头像
 * @param {*} fd 包含图片
 * @returns
 */
export function uploadPhoto(fd) {
  return request({
    method: 'patch',
    url: '/v1_0/user/photo',
    data: fd
  })
}

/**
 * 关注用户
 * @param {*} id
 * @returns
 */
export function followUser(id) {
  return request({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target: id
    }
  })
}

/**
 * 取消用户关注
 * @param {*} id
 * @returns
 */
export function unfollowUse(id) {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + id
  })
}
